package com.bird.action.user;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.bird.bean.User;
import com.bird.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

@Component(value="listUserAction")
@Scope(value="prototype")
public class ListUserAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private UserService service;

	public UserService getService() {
		return service;
	}
	
	@Resource(name="userService")
	public void setService(UserService service) {
		this.service = service;
	}
	
	@Override
	public String execute() throws Exception {
		List<User> list = service.findAllUsers();
		ServletActionContext.getRequest().setAttribute("list", list);
		return SUCCESS;
	}
}
